<template>
	<!-- 页面名称 -->
	<view class="page">
		<view class="head">
			<view class="accumulate">累计充值：{{$fn.twoToFixed(count/100)}}元</view>
			<view class="date" @click="show=true">
				{{$fn.parseTime(apiParams.datetime, "{y}-{m}")}}
				<u-icon name="arrow-down-fill" color="#333333" size="20rpx"></u-icon>
			</view>
		</view>
		<view class="main">
			<c-scroll-list ref="list" :api="api" :apiParams="apiParams" @load="load">
				<view class="list" v-for="(item,index) in cardOrderList" :key="index">
					<view class="list_l">
						<view class="name">{{item.name}}</view>
						<view class="date_time">{{$fn.parseTime(item.payTime)}}</view>
					</view>
					<view class="list_r">￥{{$fn.twoToFixed(item.price/100)}}</view>
				</view>
			</c-scroll-list>
		</view>

		<u-datetime-picker :maxDate="new Date().getTime()" :show="show" v-model="apiParams.datetime" mode="year-month"
			@cancel="show=false" @confirm="confirmDate"></u-datetime-picker>
	</view>
</template>

<script>
	export default {
		name: "topUpDetails",
		data() {
			return {
				api: this.$api.getCardOrderRecordList,
				apiParams: {
					datetime: new Date(new Date().getFullYear(), new Date().getMonth(), 1).getTime()
				},
				show: false,
				cardOrderList: [],
				count: null,
			};
		},
		onLoad() {


		},
		onShow() {
			this.getCardOrderCount();
		},
		methods: {
			// 选着日期
			confirmDate() {
				this.show = false
				this.getCardOrderCount();
				setTimeout(() => this.$refs.list.initList(true), 500)
			},
			// 获取数据列表
			load(res) {
				console.log(res.list)
				this.cardOrderList = res.list
			},
			getCardOrderCount() {
				this.$api.getCardOrderCount().then(res => {
					console.log(res.data, "累计充值(分)")
					this.count = res.data;

				})
			}
		}
	};
</script>

<style lang="scss" scoped>
	.head {
		padding: 32rpx 24rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1rpx solid #E6E6E6;

		.accumulate {
			font-weight: bold;
			font-size: 32rpx;
			color: #000000;
		}

		.date {
			font-size: 28rpx;
			color: #333333;
			display: flex;
			align-items: center;
			gap: 6rpx;
		}
	}

	.main {
		padding: 0 32rpx;
		box-sizing: border-box;

		.list {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 28rpx;
			border-bottom: 1rpx solid #E6E6E6;

			.list_l {
				.name {
					font-weight: bold;
					font-size: 32rpx;
					color: #000000;
				}

				.date_time {
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					margin-top: 12rpx;
				}
			}

			.list_r {
				font-weight: bold;
				font-size: 32rpx;
				color: #F53100;
			}

		}
	}
</style>